CC=gcc
LD=gcc
CFLAGS=-I. -I../cmn -c -Wall -Wno-deprecated-declarations
LDFLAGS=-lcrypto

UDPEXE=udpSrvr
TCPEXE=tcpSrvr

CMNOBJECTS= ../cmn/ramprakash.Part2Common.o
UDPOBJECTS= $(patsubst %UDP.c,%UDP.o,$(wildcard *UDP.c))
TCPOBJECTS= $(patsubst %TCP.c,%TCP.o,$(wildcard *TCP.c))

all: $(TCPEXE)

desdebug: CFLAGS += -g -DDESDEBUG
desdebug: $(TCPEXE)

test: CFLAGS += -DTESTING -g
test: $(TCPEXE)

debug: CFLAGS += -DDEBUG -g
debug: $(TCPEXE)

$(UDPEXE) : $(UDPOBJECTS) ../cmn/ramprakash.Part2Common.h $(CMNOBJECTS) Makefile
	$(LD) $(LDFLAGS) $(UDPOBJECTS) $(CMNOBJECTS) -o $(UDPEXE)

$(TCPEXE) : $(TCPOBJECTS) ../cmn/ramprakash.Part2Common.h $(CMNOBJECTS) Makefile
	$(LD) $(LDFLAGS) $(TCPOBJECTS) $(CMNOBJECTS) -o $(TCPEXE)

%.o :  %.c ../cmn/ramprakash.Part2Common.h Makefile ../cmn/ramprakash.Part2Common.c
	$(CC) $(CFLAGS) $< -o $@

$(CMNOBJECTS) : ../cmn/ramprakash.Part2Common.h ../cmn/ramprakash.Part2Common.c
	$(CC) $(CFLAGS) ../cmn/ramprakash.Part2Common.c -o ../cmn/$(CMNOBJECTS)

clean: 
	rm -f $(UDPOBJECTS) \
	rm -f $(UDPEXE)     \
	rm -f $(TCPOBJECTS) \
	rm -f $(TCPEXE)
